package io.renren;

import io.renren.modules.im.dao.IMMessagesDao;
import io.renren.modules.im.entity.IMMessages;
import io.renren.modules.im.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.Date;

public class DBtest {
    public static void main(String[] args) {
        insertUser();
    }


    private static void insertUser() {
        SqlSession session = MybatisUtils.getSession();
        IMMessagesDao mapper = session.getMapper(IMMessagesDao.class);
        IMMessages messages = new IMMessages();
        messages.setmFromUserID("1");
        messages.setmToUserID("2");
        messages.setmPostMessages("abc");
        messages.setmTime(new Date());
        messages.setmStatus(0);

        try {
            mapper.insert(messages);
            System.out.println(messages.toString());
            session.commit();
        } catch (Exception e) {
            e.printStackTrace();
            session.rollback();
        }
    }
}
